<HTML><HEAD><TITLE>incval(++ElemSpec)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">Non-logical Variables, Arrays, Bags, Shelves and Stores</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>incval(++ElemSpec)</H1>
Increments the contents of the visible non-logical variable or array element ElemSpec by one.
<DL>
<DT><EM>ElemSpec</EM></DT>
<DD>Atom or ground compound term with non negative integer arguments.
</DD>
</DL>
<H2>Description</H2>
   Increments the value of the element ElemSpec that must be of type
   integer.

<P>
   If ElemSpec is an atom, it must specify a non-logical variable visible from
   the caller module.
<P>
   If ElemSpec is a compound term, it must specify a visible array element.
   all its arguments must be non negative integers smaller than the bounds
   specified with array/1/2 or variable/1.

<H3>Modes and Determinism</H3><UL>
<LI>incval(++) is det
</UL>
<H3>Modules</H3>
This predicate is sensitive to its module context (tool predicate, see @/2).
<H3>Exceptions</H3>
<DL>
<DT><EM>(4) instantiation fault </EM>
<DD>ElemSpec is not instantiated.
<DT><EM>(5) type error </EM>
<DD>ElemSpec is a structure whose arguments are not all    integers.
<DT><EM>(5) type error </EM>
<DD>ElemSpec is neither an atom nor a ground structure.
<DT><EM>(5) type error </EM>
<DD>The value or type of ElemSpec is not integer.
<DT><EM>(6) out of range </EM>
<DD>Array index in ElemSpec is out of range.
<DT><EM>(41) array or global variable does not exist </EM>
<DD>ElemSpec does not designate an existing array, variable or reference.
</DL>
<H2>Examples</H2>
<PRE>
Success:
      [eclipse]: local(array(a(4), prolog)),
              setval(a(1), -2),
              incval(a(1)),
              getval(a(1), X).
      X = -1
      yes.

      [eclipse]: local(array(g(4), integer)),
              incval(g(1)),
              getval(g(1), X).
      X = 1
      yes.

      [eclipse]: setval(count, 0),
              repeat,
              writeln(hello),
              incval(count),
              getval(count, X),
              X &gt;= 3, !.
      hello
      hello
      hello
      X = 3
      yes.

Error:

      incval(X).                            (Error 4).
      incval(a(2.0)).                       (Error 5).
      setval(a, 2.0), incval(a).            (Error 5).
      local(array(a(2), float)),
          incval(a(1)).                     (Error 5).
      local(array(a(10), integer)),
          incval(a(-2)).                    (Error 6).
      incval(no_array(0)).                  (Error 41).
      incval(no_var).                       (Error 41).



</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/storage/decval-1.html">decval / 1</A>, <A HREF="../../kernel/storage/array-1.html">array / 1</A>, <A HREF="../../kernel/storage/array-2.html">array / 2</A>, <A HREF="../../kernel/storage/variable-1.html">variable / 1</A>, <A HREF="../../kernel/storage/getval-2.html">getval / 2</A>, <A HREF="../../kernel/storage/setval-2.html">setval / 2</A>
</BODY></HTML>
